﻿using System;
using System.IO;
using System.Web;
using System.Drawing;
using System.Drawing.Imaging;

/// <summary>
/// C# Date Differential
/// Object that calculates the days, months, and years... since or until another earlierDate.
/// </summary>
namespace MikeKappel.Com.CS
{
    /// <summary>
    /// 
    /// </summary>
    public static partial class Images
    {
        /// <summary>
        /// 
        /// </summary>
        public enum ImageTypes
        {
            BMP,
            JPG,
            GIF,
            ICON
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="response"></param>
        /// <param name="image"></param>
        /// <param name="type"></param>
        public static void ImageDisplay(HttpResponse response, Byte[] image, ImageTypes type)
        {
            response.Clear();
            response.StatusCode = 200;

            if (type == ImageTypes.GIF)
                response.ContentType = "image/gif";
            else if (type == ImageTypes.JPG)
                response.ContentType = "image/jpeg";
            else if (type == ImageTypes.ICON)
                response.ContentType = "image/x-icon";
            else if (type == ImageTypes.BMP)
                response.ContentType = "image/bmp";

            response.BinaryWrite(image);
            response.Flush();
            response.End();
        }
    }
}